/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.awt.Component;
import java.awt.Point;
import minemapgenerator.MyButton;

/**
 *
 * @author CodeBlue
 */
public class GameUtility {

    // params:
    // array of components (can be cast to MyButton)
    // x,y: coordinate that is stored in a button
    public static int getBombArround(Component[] components, int x, int y) {
        int count = 0;
        for (Component comp : components) {
            MyButton myBut = (MyButton) comp;
            for (int i = -1; i <= 1; i++) {
                for (int j = -1; j <= 1; j++) {
                    if (myBut.getPoint().equals(new Point(x + i, y + j)) && myBut.getBombArround() == -1) {
                        count++;
                    }
                }
            }
        }
        return count;
    }
}
